package com.janwen.j2se.thread;

import java.util.Random;

import org.apache.log4j.Logger;

/**
 * 验证threadlocal refer:http://linliangyi2007.iteye.com/blog/179040
 * 
 * @author janwen May 31, 2012
 */
public class ThreadLocalThread extends Thread {

	private static final Logger logger = Logger
			.getLogger(ThreadLocalThread.class);
	QPThreadLocal qt = new QPThreadLocal();

	public ThreadLocalThread() {
		qt.setTh();
	}

	@Override
	public void run() {
		setName("thread_" + new Random().nextInt());

		try {
			// sleep(10000);
			qt.printLocal();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			ThreadLocalThread tt = new ThreadLocalThread();
			tt.start();

		}
	}
}
